package wicresoft.servicesImp.gongXu;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import wicresoft.orm.dao.GxExpertGroupMapper;
import wicresoft.orm.entity.GxExpertGroup;
import wicresoft.orm.entity.GxExpertGroupExample;
import wicresoft.services.gongXu.GxExpertGroupServices;

import java.util.List;

/**
 * Created by Administrator on 2018/3/12.
 */
@Service
public class GxExpertGroupServicesImp implements GxExpertGroupServices {
    @Autowired
    GxExpertGroupMapper gxExpertGroupMapper;

    public List<GxExpertGroup> selectByItemId(String itemId) throws Exception {
        GxExpertGroupExample gxExpertGroupExample = new GxExpertGroupExample();
        gxExpertGroupExample.createCriteria().andItemIdEqualTo(itemId);
        return gxExpertGroupMapper.selectByExample(gxExpertGroupExample);

    }

    public int deleteByItemId(String itemId) throws Exception {

        GxExpertGroupExample gxExpertGroupExample = new GxExpertGroupExample();
        gxExpertGroupExample.createCriteria().andItemIdEqualTo(itemId);
        return gxExpertGroupMapper.deleteByExample(gxExpertGroupExample);
    }

    @Transactional
    public int insertSelective(List<GxExpertGroup> gxExpertGroupList) throws Exception {
        for (GxExpertGroup gxExpertGroup : gxExpertGroupList) {
            gxExpertGroupMapper.insertSelective(gxExpertGroup);
        }
        return gxExpertGroupList.size();
    }
}
